package com.glor.operation.common.excep;

import com.glor.operation.common.Response;
/**
 * Created by heylear.cai on 2016/2/18.
 */
public class BaseException extends Exception {

    int errorCode;

    String message;

    public BaseException(){

    }

    public BaseException(int errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
        this.message = message;
    }

    public BaseException(Response response) {
        this(response, null);
    }

    public BaseException(String message) {
        this(ErrorCode.BUSSINESS_ERROR, message);
    }

    public BaseException(Response response, String message) {
        super(message == null ? response.getMessage(): message);
        this.errorCode = response.getStatus();
        this.message = this.getMessage();
    }

    public int getErrorCode() {
        return errorCode;
    }

}
